//
//  TableViewDelegate.m
//  DebugDemo
//
//  Created by XFB on 2019/1/8.
//  Copyright © 2019年 ZhouCheng. All rights reserved.
//

#import "TableViewDelegate.h"
#import "MVVMModel.h"

@implementation TableViewDelegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (self.dataSource.count) {
        
        NSString *message = ((MVVMModel *)[self.dataSource objectAtIndex:indexPath.row]).title;
        UIViewController *vc = [UIApplication sharedApplication].keyWindow.rootViewController;
        
        UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"标题" message:message preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        }];
        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        }];
        [alertVC addAction:okAction];
        [alertVC addAction:cancelAction];
        [vc presentViewController:alertVC animated:YES completion:nil];
    }
}

@end
